<div id="once-filter" class="row">
    <style>
        #once-filter { font-size: 12px; line-height: 24px; color: #333; }
        #once-filter .input { height: 20px; line-height: 20px; padding: 0px 5px; width:120px; border-radius: 4px; border: 1px solid #ccc; }
        #once-filter .filter-ul { padding: 10px 12px; margin: 0; }
        #once-filter label { margin: 0; font-weight: normal; }
        #once-filter .title { font-weight: bold; font-size: 14px; margin: 0 5px; font-weight: bold; }
        #once-filter li { list-style: none; }
        #once-filter li.li-inline { display: inline-block; margin: 4px 0; padding: 0; min-height: 28px; max-width: 80%; line-height: 28px; vertical-align: middle; }
        #once-filter ul.ul-inline { display: inline-block; padding: 0; }
        #once-filter div.div-inline { display: inline-block; vertical-align: top; }
        #once-filter .time-range .reportrange { padding: 2px 12px; }

        .nav-links>li { float: left; }
        .nav.nav-links > li > a { border-radius: 4px; padding: 0px 8px; text-decoration: underline; }
        .nav-links>li.active>a, .nav-links>li.active>a:hover, .nav-links>li.active>a:focus { color: #fff; background-color: #428bca; text-decoration: none; }

        #once-filter li.li-inline.float{ box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1); border-bottom: 1px solid #ccc; height: 44px; width: 100%; text-align: center; line-height: 24px; padding: 10px 0; position: fixed; margin: 0; top: 0; left: 0px; background: #ffffff; z-index: 9; }

        #filter-btn { position: absolute; right: 10px; bottom: 10px; }
        
        .webuploader-pick{padding:2px 19px;background:#5cb85c;margin-top: 4px;overflow:unset;}
    </style>
 <script>
 	var spe_is_load = 1;
 	var os_is_load = 1;
 </script>   



    <div class="col-md-12">
        <form method="get" action="" id="filter-form">
            <div class="normal-setting" style="display: none;">
                <input type="text" name="r" data-target="" value="<{$beforeAction.Current.Route}>"/>
                <input type="text" name="m" value="<{$beforeAction.Current.MenuID}>"/>

                <{if isset($beforeAction.Current.GameSrc)}><input type="text" name="g" value="<{$beforeAction.Current.GameSrc}>"/><{/if}>

                <{if isset($beforeAction.Current.Platform)}><input type="text" name="p" value="<{$beforeAction.Current.Platform}>"/><{/if}>
            </div>

            <div class="box box-black">
            	<{if $ajax_search == 1 }>
            		<a href="#" class="btn btn-default btn-flat" style="position:absolute;right:100px;bottom:10px" id="ajax_search"><i class="fa fa-search" ></i> 查询</a>
            	<{else}>            	
                <button id="filter-btn" class="btn btn-default btn-flat" <{if $btn == 'export'}>style="position:absolute;right:100px;bottom:10px" <{/if}>><i class="fa fa-search" ></i> 查询</button>
                <{/if}>
                	
                <!--自己认领的导出-->
                <{if $btn == 'export'}><button id="export-btn" class="btn btn-purple btn-flat" style="position:absolute;right:10px;bottom:10px"><i class="fa fa-file-excel-o"></i> 导出</button><{/if}>
                <!--统一导出-->
                <{if isset($filter['_export'])}>
                    <style>
                        #filter-btn { right: 90px; };
                    </style>

                    <div id="export-btn" for="<{$filter['_export']['name']}>" class="btn btn-purple btn-flat" style="position:absolute;right:10px;bottom:10px"><i class="fa fa-file-excel-o"></i> 导出</div>

                    <script>
                        $(function(){
                            $("#export-btn").click(function(){
                                var url = window.location.origin + window.location.pathname + '?' + $(this).attr('for') + '=1&_t=' + new Date().getTime() + '&' + $("#filter-form").serialize();
                                //alert(url);return false;
                                //alert($("#filter-form").serialize());return false;
                                window.open(url);
                            });
                        });
                    </script>
                <{/if}>
                
                <!--导入-->
                <{if isset($filter['_import'])}>	
                	<div id="filePicker" data-url="<{$filter['_import']['url']}>" name="<{$filter['_import']['name']}>" style="position:absolute;right:250px;bottom:10px">导入</div>	
                <{/if}>
                	
                <div style="width: 80%;">


                    <ul class="filter-ul">
                        <{foreach from=$filter item=item key=key}>

                        <{if $item.type == 'btn'}>

                        <{else if $item.type == 'br'}>
                        <br/>
                        <{else if $item.type == 'symbol'}>
                        <li class="li-inline" for="<{$item.name}>" <{if $item.args.fixed}>fixed<{/if}>>
                            <label class="title"><{$item.name nofilter}></label>
                        </li>
                        <{else}>
                        <li class="li-inline" for="<{$item.name}>" id="<{$item.name}>" <{if $item.args.fixed}>fixed<{/if}>>
                            <{if !empty($item.title)}><label class="title"><{$item.title}></label><{/if}>

                            <!-- 文本输入框 -->
                            <{if $item.type == 'input'}>
                            <input type="text" id="input-<{$item.name}>" name="<{$item.name}>" class="input" value="<{$item.value}>"
                                <{if !empty($item['args']['date'])}>date="<{if is_string($item['args']['date'])}><{$item['args']['date']}><{else}>day<{/if}>"<{/if}>
                                <{if !empty($item['args']['autocomplete'])}>autocomplete="false" autocomplete-source="<{$item['args']['autocomplete']}>"<{/if}>
                                <{$item.attr nofilter}> />

                            <!-- 隐藏框 -->
                            <{elseif $item.type == 'hidden'}>
                            <input type="hidden" id="hidden-<{$item.name}>" name="<{$item.name}>" value="<{$item.value}>" />

                            <!-- 多行文本输入框 textarea -->
                            <{elseif $item.type == 'textarea'}>
                            <textarea name="<{$item.name}>"><{$item.value}></textarea>

                            <!-- 上传文件 -->
                            <{elseif $item.type == 'file'}>
                            <input id="<{$item.name}>" name="<{$item.name}>" type="file" style="display: inline;line-height: normal"/>

                            <!-- 选择框 -->
                            <{elseif $item.type == 'select'}>
                            <select id="select-<{$item.name}>" sel="<{$item.value}>" name="<{$item.name}>" <{if !empty($item['args']['chosen'])}>chosen<{/if}> <{$item.attr nofilter}>>
                            <{html_options options=$item.args.options selected=$item.value}>
                            </select>
                            
                            <!-- 选择框 -->
                            <{elseif $item.type == 'searchSelect'}>
                            <select id="select-<{$item.name}>" sel="<{$item.value}>" name="<{$item.name}>" <{if !empty($item['args']['chosen'])}>chosen<{/if}> <{$item.attr nofilter}>>
                            <{html_options options=$item.args.options selected=$item.value}>
                            </select>
                            <script>
                            	
                            	$(function(){
                            		var se_name = '<{$item.name}>';
                            		
                            		if(se_name == 'special_id'){
                            			$('select[name="special_id"]').searchableSelect({width: 130,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7,onChange:onChange_special});	
                            		}
                            		if(se_name == 'os'){
                            			$('select[name="os"]').searchableSelect({width: 130,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7,onChange:onChange_os});
                            		}
                            		if(se_name == 'server'){
                            			$('select[name="server"]').searchableSelect({width: 150,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7});
                            		}
                            		
	                            });
                            </script>
                            
                            <!-- 选择框 -->
                            <{elseif $item.type == 'searchableSelect'}>
                            <select id="select-<{$item.name}>" sel="<{$item.value}>" name="<{$item.name}>" <{if !empty($item['args']['chosen'])}>chosen<{/if}> <{$item.attr nofilter}>>
                            <{html_options options=$item.args.options selected=$item.value}>
                            </select>
                            <script>

                            	$(function(){
                            		var se_name = '<{$item.name}>';
                            		
                            		if(se_name == 'special_id'){
                            			$('select[name="special_id"]').searchableSelect({width: 130,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7,onChange:SonChange});	
                            		}
                            		
                            		if(se_name == 'os'){
                            			//$('select[name="os"]').searchableSelect({width: 100,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7,onChange:onChange});	
                            		}
                            		
                            		if(se_name != 'os' && se_name != 'server' && se_name != 'special_id'){
                            			$('select[name="<{$item.name}>"]').searchableSelect({
		                                    width: 150,
		                                    size: 12,
		                                    height: 18,
		                                    padding1: 1,
		                                    padding2: 6,
		                                    top : 4,
		                                    right: 7
	                                    });
                            		}    
	                            });
                            </script>

                            <{elseif $item.type == 'radio'}>
                            <ul class="ul-inline">
                                <{foreach from=$item.args.options key=kk item=ii}>
                                <li class="li-inline">
                                    <input id="radio-<{$key}>-<{$kk}>" name="<{$item.name}>" type="radio" value="<{$kk}>" <{if $kk == $item.value}>checked<{/if}> />
                                    <label for="radio-<{$key}>-<{$kk}>"><{$ii}></label>
                                </li>
                                <{/foreach}>
                            </ul>

                            <{elseif $item.type == 'timerange'}>

                            <div class="time-range div-inline">
                                <button class="reportrange btn btn-default" for="<{$item.name}>" start="<{substr($item.value, 0, 10)}>" end="<{substr($item.value, 13, 10)}>" <{if $item.args.min}>min="<{$item.args.min}>"<{/if}> <{if $item.args.max}>max="<{$item.args.max}>"<{/if}> >
                                    <i class="fa fa-calendar"></i>
                                    <span><{if empty($item.value)}>选择日期<{else}><{$item.value}><{/if}></span>
                                    <i class="fa fa-caret-down"></i>
                                </button>
                                <input type="hidden" name="<{$item.name}>" value="<{$item.value}>" class="range" />
                            </div>

                            <{elseif $item.type == 'button'}>
                                <button name="<{$item.name}>" value="<{$item.value}>" class="btn btn-default btn-flat btn-mi"><{$item.args.options.text}></button>

                            <{elseif $item.type == 'checkbox'}>
                            <ul class="ul-inline">
                                <{foreach from=$item.args.options key=kk item=ii}>
                                <li class="pull-left" style="padding:0px 5px">
                                    <input id="checkbox-<{$key}>-<{$kk}>" name="<{$item.name}>[]" type="checkbox" class="simple" value="<{$kk}>" <{if in_array($kk, $item.value)}>checked<{/if}> />
                                    <label for="checkbox-<{$key}>-<{$kk}>"><{$ii}></label>
                                </li>
                                <{/foreach}>
                            </ul>
                            <{elseif $item.type == 'link'}>
                            <div class="div-inline">
                                <ul class="ul-inline nav nav-links" role="tablist">
                                    <{foreach from=$item.args.options key=kk item=ii}>
                                    <li <{if $kk == $item.value}>class="active"<{/if}>><a href="javascript:;" class="link-btn" key="<{$kk}>"><{$ii}></a></li>
                                    <{/foreach}>
                                </ul>
                                <input type="hidden" name="<{$item.name}>" value="<{$item.value}>" />
                            </div>
                            <{/if}>
                        </li>
                        <{/if}>
                        <{/foreach}>
                    </ul>
                </div>
            </div>
            <{if $is_log == 1}>
            <input type="hidden" name="log_s" value="1"/>
            <{/if}>
            <{if $is_ana == 2}>
            <input type="hidden" name="ana_s" value="2"/>
            <{/if}>
        </form>
    </div>
    <!--
    	表单为searchSelect时的所用方法start
    -->
    <script>
    	                        var onChange_special = function(val){
                            		var special_id = val;
        	                        var g = $("input[name='g']").val();
        	                        var url = '/oss/?r=channel/getChannelForSpecial&g='+g;
        	                        var os = GetQueryString('os');
        	                        //console.log(spe_is_load);
        	                        if(spe_is_load == 1){
        	                        	spe_is_load = 2;
        	                        	return false;
        	                        }
        	                        
        	                        
        	                        
        	                        $.ajax({
        	                        	type : 'POST',
        	                        	url : url,
        	                        	data : {'special_id':special_id},
			                            dataType :'JSON',
			                            success : function(res){
			                            	if(res.status == 1){
			                            		var option = '';					    
					                            for (var i=0;i<res.data.list.length;i++){
					    	                        var selected = '';
					    	                        if(res.data.list[i]['tab'] == os){
					    		                       selected = 'selected';
					    	                        }
						                            option += "<option "+selected+" value='"+res.data.list[i]['tab']+"'>"+res.data.list[i]['channel_name']+"</option>";
					                            }

					    
					                            if(res.data.IsViewAll == 1){
					                            	var selected = '';
					                            	if('ALL' == os){
					                            		selected = 'selected';
					                            	}
						                            option += "<option "+selected+" value='ALL'>ALL</option>";
					                            }
					                            
					                            $('select[name="os"]').empty();
					                            $('select[name="os"]').append(option);
					                            $('#os').text('');
					    
					                            var select = '<label class="title">渠道</label><select class="form-control" name="os">'+option+'</select>';
					    
					                            $('#os').html(select);
					                            $('#os').find('select[name="os"]').searchableSelect({width: 130,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7,onChange:onChange_os});
					    
					                            
				                            }else{
				                            	$('select[name="os"]').empty();
				                            }
			                            }
	                                });
                                };

                                var onChange_os = function(val){
                                	var special_id = $("select[name='special_id']").val();
                            		var os = val;
        	                        var g = $("input[name='g']").val();
        	                        var url = '/oss/?r=channel/getServer&g='+g;
        	                        var is_log = $("input[name='is_log']").val();
        	                        var server = GetQueryString('server');
        	                        //console.log(server);
        	                        if(os_is_load == 1){
        	                        	os_is_load = 2;
        	                        	return false;
        	                        }
        	                        $.ajax({
        	                        	type : 'POST',
        	                        	url : url,
        	                        	data : {'os':os,'g':g,'special_id':special_id},
			                            dataType :'JSON',
			                            success : function(res){
			                            	if(res.status == 1){
			                            		var option = '';
					                            if(is_log != 1 && res.data.IsViewAll == 1){
					                            	var selected = '';
					                            	if('ALL' == os){
					                            		selected = 'selected';
					                            	}
						                            option += "<option "+selected+" value='ALL'>全服</option>";
					                            }
					                            for (var i=0;i<res.data.list.length;i++){
					                            	var selected = '';
					    	                        if(res.data.list[i]['develop_id'] == server){
					    		                       selected = 'selected';
					    	                        }
						                            option += "<option "+selected+" value='"+res.data.list[i]['develop_id']+"'>"+res.data.list[i]['server_name']+" ("+res.data.list[i]['server_num']+")</option>";
					                            }
				    	                        
				    	                        
					                            $('select[name="server"]').empty();
					                            $('select[name="server"]').append(option);
					                            $('#server').text('');
					    
					                            var select = '<label class="title">服务器</label><select class="form-control" name="server">'+option+'</select>';
					    
					                            $('#server').html(select);
					                            $('#server').find('select[name="server"]').searchableSelect({width: 150,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7});
				                            }else{
				                            	$('select[name="server"]').empty();
				                            }
			                            }
	                                });
                                };
    </script>
    <!--
    	表单为searchSelect时的所用方法end
    -->
    
    <!--
    	表单为searchableSelect时的所用方法start
    -->
    <script>
    	                    var SonChange = function(val){
                            		var special_id = val;
        	                        var g = $("input[name='g']").val();
        	                        var url = '/oss/?r=channel/getChannelForSpecial&g='+g;
        	                        var os = GetQueryString('os');
        	                        //console.log(server);
        	                        $.ajax({
        	                        	type : 'POST',
        	                        	url : url,
        	                        	data : {'special_id':special_id},
			                            dataType :'JSON',
			                            success : function(res){
			                            	if(res.status == 1){
			                            		var option = '';
			                            		option += "<option value=''>请选择</option>";
				    	                        for (var i=0;i<res.data.list.length;i++){
				    	                        	if(res.data.list[i]['tab'] == os){
				    	                        		option += "<option selected='selected' value='"+res.data.list[i]['tab']+"'>"+res.data.list[i]['channel_name']+"</option>";
				    	                        	}else{
				    	                        		option += "<option value='"+res.data.list[i]['tab']+"'>"+res.data.list[i]['channel_name']+"</option>";
				    	                        	}
					                            }
				    	                        
				    	                        if(res.data.list.length > 0){
				    	                        	var selected = '';
					                            if('ALL' == os){
					                            	selected = 'selected';
					                            }
						                        option += "<option "+selected+" value='ALL'>ALL</option>";
				    	                        }
				    	                        
				    	                        
					                            $('select[name="os"]').empty();
					                            $('select[name="os"]').append(option);
					                            $('#os').text('');
					    
					                            var select = '<label class="title">渠道</label><select class="form-control" name="os">'+option+'</select>';
					    
					                            $('#os').html(select);
					                            $('#os').find('select[name="os"]').searchableSelect({width: 130,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7,onChange:onChange});
				                            }else{
				                            	$('select[name="os"]').empty();
				                            }
			                            }
	                                });
                                };

                            	var onChange = function(val){
                            		var os = val;
        	                        var g = $("input[name='g']").val();
        	                        var url = '/oss/?r=channel/getServer&g='+g;
        	                        var server = GetQueryString('server');
        	                        //console.log(server);
        	                        var special_id = $("select[name='special_id']").val();        	                        
//      	                        if(os == 'ALL' && special_id == ''){
//      	                        	layer.msg('请先选择专服', {icon: 2,time: 2000});
//      	                        	return false;
//      	                        }
        	                        if(os == 'ALL'){
        	                        	var send_data = {'os':os,'g':g,'special_id':special_id};
        	                        }else{
        	                        	var send_data = {'os':os,'g':g};
        	                        }

        	                        $.ajax({
        	                        	type : 'POST',
        	                        	url : url,
        	                        	data : send_data,
			                            dataType :'JSON',
			                            success : function(res){
			                            	if(res.status == 1){
			                            		var option = '';
			                            		option += "<option value='0'>请选择</option>";
				    	                        for (var i=0;i<res.data.list.length;i++){
				    	                        	if(res.data.list[i]['server_id'] == server){
				    	                        		option += "<option selected='selected' value='"+res.data.list[i]['server_id']+"'>"+res.data.list[i]['server_name']+" ("+res.data.list[i]['server_num']+")</option>";
				    	                        	}else{
				    	                        		option += "<option value='"+res.data.list[i]['server_id']+"'>"+res.data.list[i]['server_name']+" ("+res.data.list[i]['server_num']+")</option>";
				    	                        	}

					                            }
					                            $('select[name="server"]').empty();
					                            $('select[name="server"]').append(option);
					                            $('#server').text('');
					    
					                            var select = '<label class="title">服务器</label><select class="form-control" name="server">'+option+'</select>';
					    
					                            $('#server').html(select);
					                            $('#server').find('select[name="server"]').searchableSelect({width: 150,size: 12,height: 18,padding1: 1,padding2: 6,top : 4,right: 7});
				                            }else{
				                            	$('select[name="server"]').empty();
				                            }
			                            }
	                                });
                                };
    </script>
    <!--
    	表单为searchableSelect时的所用方法end
    -->
    

    <script type="text/javascript">
        $(function(){
            $('select[name="period"]').change(function(){

                var selectVal = $(this).find('option:selected').val()
                var config    = {
                                    format: 'yyyy-mm',
                                    datemode: 'dmUpDown',
                                    fontAwesome: true,
                                    todayBtn:  true,
                                    todayHighlight: true,
                                    autoclose: true,
                                    startView: 3,
                                    minView: 3
                                }

                if(selectVal == 'Monthly'){

                    $('#once-filter input[date]').each(function(){
                        var setVal = $(this).val().substr(0, 7)

                        $(this).datetimepicker("remove").val(setVal).datetimepicker(config).datetimepicker('update');

                    })
                    
                }else if(selectVal == 'Daily' || selectVal == 'Weekly'){
                    config['format'] = 'yyyy-mm-dd'
                    config['startView'] = 2
                    config['minView'] = 2

                    var startDate   = $('#once-filter input[name="time_start"]')
                    var endDate     = $('#once-filter input[name="time_end"]')
                    var CurrDate = new Date(startDate.val());
                    var d = CurrDate.getDate()
                    var m = CurrDate.getMonth() + 1
                    var y= CurrDate.getFullYear()
                    if(d < 10)
                        d = "0"+d
                    if(m < 10)
                        m = "0"+m
                    var setStartVal = y+"-"+m+"-"+d
                    var CurrDate = new Date(endDate.val());
                    var d = CurrDate.getDate()
                    var m = CurrDate.getMonth() + 1
                    var y= CurrDate.getFullYear()
                    if(d < 10)
                        d = "0"+d
                    if(m < 10)
                        m = "0"+m
                    var setEndVal = y+"-"+m+"-"+d
                    startDate.datetimepicker("remove").val(setStartVal).datetimepicker(config).datetimepicker('update');
                    endDate.datetimepicker("remove").val(setEndVal).datetimepicker(config).datetimepicker('update');

                }

            })

            $('#select-p').on('change', function(){

                var pl = $('#select-p').find('option:selected').val()
                var url  = '/home/?r=api/getServer'
                var game   = $('#filter-form').find('input[name="g"]').val()

                $('#select-server').html('')
                $.get(url, { p : pl, g : game }, function(data){
                    $.each(data, function(key, val){
                        $('<option>', {
                            text  : val,
                            value : key
                        }).appendTo($('#select-server'))
                    })

                    if($('#select-server').attr('chosen') != undefined ){
                        $('#select-server').trigger("chosen:updated");
                    }

                }, 'json')
            })
            
            <{if $fiter_special != 1 }>
            $.fn.datetimepicker.dates['zh-CN'] = {  
                days:       ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六","星期日"],  
                daysShort:  ["日", "一", "二", "三", "四", "五", "六","日"],  
                daysMin:    ["日", "一", "二", "三", "四", "五", "六","日"],  
                months:     ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月","十二月"],  
                monthsShort:  ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],  
                meridiem:    ["上午", "下午"],  
                //suffix:      ["st", "nd", "rd", "th"],  
                today:       "今天"  
            };
            <{/if}>

            $('#once-filter input[date]').each(function(){
                var config = {
                	language: 'zh-CN',
                    format: 'yyyy-mm-dd',
                    datemode: 'dmUpDown',
                    fontAwesome: true,
                    todayBtn:  true,
                    todayHighlight: true,
                    autoclose: true,
                    startView: 2,
                    minView: 2
                };

                if($(this).attr('date') === 'month'){
                    config['format'] = 'yyyy-mm';
                    config['startView'] = 3;
                    config['minView'] = 3;
                }

                $(this).datetimepicker(config);
            });


            function log( message ) {
                $( "<div>" ).text( message ).prependTo( "#log" );
                $( "#log" ).scrollTop( 0 );
            }

            $("#once-filter input[autocomplete-source]").each(function(){
                var name = $(this).attr('name'),
                    source = $(this).attr('autocomplete-source');

                $(this).autocomplete({
                    source: function( request, response ) {
                        $.ajax({
                            url: source,
                            dataType: "json",
                            data: {
                                q: request.term
                            },
                            success: function( data ) {
                                response( data );
                            }
                        });
                    }
                });
            });

            $("#once-filter .link-btn").click(function(){
                var value = $(this).attr('key'),
                        li = $(this).closest('li'),
                        ul = li.closest('ul'),
                        input = ul.next('input');

                ul.find('li').removeClass('active');
                li.addClass('active');
                input.val(value);
            });

            <{if $fiter_special != 1 }>
            $('#once-filter select[chosen]').css('minWidth', '120px').chosen();
            <{/if}>
            
            <{if $is_his == 1 }>
            $('#once-filter .reportrange').each(function(){
                var the = $(this);

                the.daterangepicker(
                    {
                    	timePicker: true, //显示时间
                        timePicker12Hour: false, //时间制
                        format: 'YYYY.MM.DD HH:mm',
                        locale: {
                            applyLabel: '确定',
                            cancelLabel: '取消',
                            'customRangeLabel': '自定义时段',
                            'toLabel': '结束时间',
                            'fromLabel': '开始时间',
                            "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
                            "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
                        },
                        ranges: {
                            '今天': [moment(), moment()],
                            '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                            '最近7天': [moment().subtract('days', 6), moment()],
                            '最近30天': [moment().subtract('days', 29), moment()],
                            '本月': [moment().startOf('month'), moment().endOf('month')],
                            '上月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
                        },
                        startDate: the.attr('start') || '2014.10.19',
                        endDate: the.attr('end') || '2014.10.19',
                        maxDate: the.attr('max') || false,
                        minDate: the.attr('min') || false,
                    },
                    function(start, end) {
                        var theDiv = the.closest('.time-range'),
                                range = start.format('YYYY.MM.DD HH:mm') + ' ~ ' + end.format('YYYY.MM.DD HH:mm');

                        the.find('span').html(range);
                        theDiv.find('.range').val(range);
                    }
                );
            });
            <{else}>
            $('#once-filter .reportrange').each(function(){
                var the = $(this);

                the.daterangepicker(
                    {
                        format: 'YYYY.MM.DD',
                        locale: {
                            applyLabel: '确定',
                            cancelLabel: '取消',
                            'customRangeLabel': '自定义时段',
                            'toLabel': '结束时间',
                            'fromLabel': '开始时间',
                            "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
                            "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
                        },
                        ranges: {
                            '今天': [moment(), moment()],
                            '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                            '最近7天': [moment().subtract('days', 6), moment()],
                            '最近30天': [moment().subtract('days', 29), moment()],
                            '本月': [moment().startOf('month'), moment().endOf('month')],
                            '上月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
                        },
                        startDate: the.attr('start') || '2014.10.19',
                        endDate: the.attr('end') || '2014.10.19',
                        maxDate: the.attr('max') || false,
                        minDate: the.attr('min') || false,
                    },
                    function(start, end) {
                        var theDiv = the.closest('.time-range'),
                                range = start.format('YYYY.MM.DD') + ' ~ ' + end.format('YYYY.MM.DD');

                        the.find('span').html(range);
                        theDiv.find('.range').val(range);
                    }
                );
            });
            <{/if}>

            var fixedFilter = $("#once-filter .filter-ul > li[fixed]");
            if(fixedFilter.length > 0){
                var offsetTop   = fixedFilter.offset().top,
                    critical    = offsetTop;

                $(window).scroll(function(){
                    if($(this).scrollTop() > critical){
                        if(!fixedFilter.hasClass('float')) {
                            $('<li class="tmp-fixed li-inline"><label></label></li>').insertBefore(fixedFilter)
                            fixedFilter.addClass('float');
                        }
                    }else{
                        if(fixedFilter.hasClass('float')) {
                            $("li.tmp-fixed").remove();
                            fixedFilter.removeClass('float');
                        }
                    }
                });
            }
        });
    </script>
</div>


<!--导入-->
<{if isset($filter['_import'])}>	
<script>
   var g = $("input[name='g']").val();
   var uploading = null;
   var url = $("#filePicker").attr('data-url');
   $(function(){
	   var uploader = uploadFile({
    	  //server:"?r=goods/importGoods&g="+g,
    	  server:url,
    	  pick:'#filePicker',
    	  fileSizeLimit: 3*1024*1024,
    	  formData: {dir:'temp'},
    	  callback:function(f,file){
    		  layer.close(uploading);
    		  json = eval("("+f+")");
    		  if(json.status==1){
    			  uploader.removeFile(file);
    			  uploader.refresh();
    			  layer.alert('导入数据成功!'+json.msg, {
						skin: 'layui-layer-molv' //样式类名
						,closeBtn: 0
				  }, function(){
						window.location.reload();
				  });
    		      //layer.msg('导入数据成功!'+json.msg, {icon: 1});
    		  }else{
    			  layer.msg('导入数据失败,出错原因：'+json.msg, {icon: 5});
    		  }
	      },
	      progress:function(rate){
	    	  uploading = layer.load(2, {shade: [0.6, '#393D49']});
	      }
      });
   });

function uploadFile(opts){
	var _opts = {};
	_opts = $.extend(_opts,{auto: true,swf: '/public/static/plugin/webuploader/Uploader.swf'},opts);
	var uploader = WebUploader.create(_opts);
	uploader.on('uploadSuccess', function( file,response ) {
		//console.log(response);
	    var json = response._raw;
	    if(_opts.callback)_opts.callback(json,file);
	});
	uploader.on('uploadError', function( file ) {
		layer.msg('上传失败!', {icon: 5});
	});
	uploader.on( 'uploadProgress', function( file, percentage ) {
		if(_opts.progress)_opts.progress(percentage);
	});
	return uploader;
}

</script>
<{/if}>
	
<script>
	$(function(){
		$('select[name="special_id"]').change(function(){
			var special_id = $(this).val();
			var g = $("input[name='g']").val();
			var url = '/oss/?r=channel/getChannelForSpecial&g='+g;
			var os = GetQueryString('os');
			var is_log = $("input[name='is_log']").val();
			$.ajax({
    		    type : 'POST',
    		    url : url,
			    data : {'special_id':special_id},
			    dataType :'JSON',
			    success : function(res){
				    if(res.status == 1){
					    var option = '';					    
					    for (var i=0;i<res.data.list.length;i++){
					    	var selected = '';
					    	if(res.data.list[i]['tab'] == os){
					    		selected = 'selected';
					    	}
						    option += "<option "+selected+" value='"+res.data.list[i]['tab']+"'>"+res.data.list[i]['channel_name']+"</option>";
					    }
//					    if(res.data.IsViewAll == 1 && is_log == 1){
//						    option += "<option value='ALL'>ALL</option>";
//					    }
					    
					    if(res.data.IsViewAll == 1){
						    option += "<option value='ALL'>ALL</option>";
					    }
					    
					    $('select[name="os"]').empty();
					    $('select[name="os"]').append(option);
					    $('select[name="os"]').change();
				    }else{
					    $('select[name="os"]').empty();
				    }
			    }
		    });	
		});
		
        $('select[name="os"]').change(function(){
        	var special_id = $("select[name='special_id']").val();
        	var os = $(this).val();
        	var g = $("input[name='g']").val();
        	var url = '/oss/?r=channel/getServer&g='+g;
        	var is_log = $("input[name='is_log']").val();
        	//console.log(is_log);
        	$.ajax({
    		    type : 'POST',
    		    url : url,
			    data : {'os':os,'g':g,'special_id':special_id},
			    dataType :'JSON',
			    success : function(res){
				    if(res.status == 1){
					    //console.log(res.data.IsViewAll);
					    var option = '';
					    if(is_log != 1 && res.data.IsViewAll == 1){
						    option += "<option value='ALL'>全服</option>";
					    }
					    for (var i=0;i<res.data.list.length;i++){
						
						    option += "<option value='"+res.data.list[i]['develop_id']+"'>"+res.data.list[i]['server_name']+" ("+res.data.list[i]['server_num']+")</option>";
					    }
					    $('select[name="server"]').empty();
					    $('select[name="server"]').append(option);
				    }else{
					    $('select[name="server"]').empty();
				    }
			    }
		    });	
        });
        
        
        $('select[name="special_id_s"]').change(function(){
			var special_id = $(this).val();
			var g = $("input[name='g']").val();
			var server_id = GetQueryString('server_id');
			var url = '/oss/?r=channel/getServerForSpecial&g='+g;
			if(special_id == ''){
				var option = '';	
				option += "<option value=''>请选择</option>";
				$('select[name="server_id"]').empty();
				$('select[name="server_id"]').append(option);
				return false;
			}
			$.ajax({
    		    type : 'POST',
    		    url : url,
			    data : {'special_id':special_id},
			    dataType :'JSON',
			    success : function(res){
				    if(res.status == 1){
					    var option = '';	
					    option += "<option value=''>请选择</option>";
					    for (var i=0;i<res.data.length;i++){
					    	var selected = '';
					    	if(res.data[i]['server_id'] == server_id){
					    		selected = 'selected';
					    	}
						    option += "<option "+selected+" value='"+res.data[i]['server_id']+"'>"+res.data[i]['server_name']+" ("+res.data.list[i]['server_num']+")</option>";
					    }						

					    $('select[name="server_id"]').empty();
					    $('select[name="server_id"]').append(option);

				    }else{
					    $('select[name="server_id"]').empty();
				    }
			    }
		    });	
		});
        
    });
</script>